﻿/****************************** Module Header ******************************\
 * Module Name:  ExMethodForCheckBoxList.cs
 * Module Version:  1.0.0 (2012-4-11)
 * Copyright (c) AnyEB.Com (14507247@qq.com)
 * 
 * This class is used to extension webcontrol instance's method.  It supplies 
 * public static extension methods to load data or get othor control.
 * 
 * This source is subject to the GPL License.
 * See http://www.gnu.org/licenses/gpl.html.
 * All other rights reserved.
 * 
 * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 
 * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/

using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;

namespace UCF.Core.Web
{
    /// <summary>
    /// TreeView服务器控件扩展方法
    /// </summary>
    public static class ExMethodForTreeView
    {
        /// <summary>
        /// 获取选中的所有值
        /// </summary>
        /// <param name="o"></param>
        /// <param name="format"></param>
        /// <param name="splitor"></param>
        /// <returns></returns>
        public static string GetCheckedValues(this TreeView o,string format="{0}",string splitor=",")
        {
            StringBuilder sb = new StringBuilder();
            foreach (TreeNode n in o.CheckedNodes)
            {
                sb.AppendFormat("{0}{1}", string.Format(format,n.Value), splitor);
            }
            return sb.Length > 0 ? sb.Remove(sb.Length - splitor.Length, splitor.Length).ToString() : "";
        }
    }
}
